home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-16 | 2.3 KB | 77 lines | [TEXT/MPS ] |
- #----------------------------------------------------------------------------------------------------------------------------------------------------
- # MarkIt
- # MPW Script
- # Written by Gina Cherry • August 16, 1991
- # Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
- #
- # Usage:
- # MarkIt [file…]
- #
- # Function:
- # MarkIt creates markers for all C functions (either ANSI or old-style C) in the specified files.
- # If a file name is not given on the command line, MarkIt operates on the target file.
- #
- # Note:
- # MarkIt may be used with the Commando option.
- #----------------------------------------------------------------------------------------------------------------------------------------------------
-
- # Don't exit script on error.
- Set Exit 0
-
- # Initialize variables.
- Set Files ""
- Set Word '[a-zA-Z0-9_]+'
-
- # If no parameter is given, set Files to the target file; otherwise set Files to the given parameters.
- For file in {"Parameters"}
- Set Files "{Files} '{file}'"
- End
- If {Files} == ""
- Set Files "'{Target}'"
- End
-
- # Loop through parameters
- For fName in {Files}
- # Record whether fName is already open.
- Set fullName "`Files -i -f "{fName}" ≥ Dev:Null`"
- Set wasOpen `Evaluate "∂`Windows∂`" =~ /≈{fullName}≈/`
-
- # Open the file fName. If the file can't be opened, print an error message and exit script.
- Open "{fName}" ≥ Dev:Null
- If {Status} != 0
- Echo "### {0}: File {fName} not found."
- Continue
- End >> Dev:StdErr
-
- # Go to the top of the input file.
- Find • "{fName}"
-
- # Loop until no more functions in input file.
- Loop
-
- # Position cursor at beginning of function.
- Find Δ/•{Word}[ ∂n∂t∂*a-zA-Z_0-9]*∂([ ∂t∂n∂*a-zA-Z_0-9∂[∂],]*[∂)][¬;∂)∂n]*∞/ "{fName}"
-
- # Break if no more functions.
- Break If {Status}
-
- # Select left paren.
- Find /∂(/ "{fName}"
-
- # Select the first word preceding the left paren.
- Find \[¬ ∂t∂n]\:\[ ∂t∂n∂*]\!0 "{fName}"
-
- # Create a marker with the name of the current function. Overwrite any existing marker
- # with the same name.
- Mark -y § "`catenate "{fName}.§"`" "{fName}"
-
- # Position cursor at end of function.
- Find /∂{/ "{fName}"
- MatchIt -c "{fName}"
- End
-
- # Close the file if it wasn't open to start with.
- If !"{wasOpen}"
- Close "{fName}" ≥ Dev:Null
- End
- End